package org.nlp.algo.classifier;

import com.aliasi.spell.TfIdfDistance;

public class TfIdfDistanceDemo {
	public static void main(String[] args) {
		CharSequence cSeq = "长春市长春节讲话";
		String s1 = "长春";
		String s2 = "春节";
		LuceneTokenizerFactory tokenizerFactory = LuceneTokenizerFactory.INSTANCE;
		TfIdfDistance tfIdf = new TfIdfDistance(tokenizerFactory);
		tfIdf.handle(cSeq);
		System.out.printf("\n %18s %8s %8s\n", "Term", "Doc Freq", "IDF");
		for (String term : tfIdf.termSet())
			System.out.printf(" %18s %8d %8.2f\n", term,
					tfIdf.docFrequency(term), tfIdf.idf(term));

		System.out.println("\nString1=" + s1);
		System.out.println("String2=" + s2);
		System.out.printf("distance=%s proximity=%s\n", tfIdf.distance(s1, s2),
				tfIdf.proximity(s1, s2));

	}
}